// 路径规划
export const goView = (map:any, AMapObj:any, startName:any, endName:any, rule:any, routeArr:any, polictText:any) => {
  // eslint-disable-next-line no-undef
  const driving = new AMapObj.Driving({
    map,
    // 驾车路线规划策略，AMap.DrivingPolicy.LEAST_TIME是最快捷模式
    // eslint-disable-next-line no-undef
    // policy: AMapObj.DrivingPolicy.LEAST_TIME  // 路线最快
    policy: rule  // 路线最快
  })
  const points = [
    { keyword: startName, city: '广州' },
    { keyword: endName, city: '广州' }
  ]

  driving.search(points, (status: any, result: any) => {
    // 未出错时，result即是对应的路线规划方案
    console.log('status=', status)
    console.log('result=', result)
    if (status === 'complete') {
      routeArr = result.routes[0].steps
      polictText = result.routes[0].policy
      console.log(routeArr)
    }
  })
}